#include "mainwindow.h"
#include "./ui_mainwindow.h"
#include "gui_buscap_calc.h"
#include <QDebug>
#include <QWidget>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    setWindowTitle("硬件工具");

    // 工具栏定义
    toolbar  = new QToolBar(this);
    toolbar->setFloatable(false);
    toolbar->setMovable(false);
    toolbar->setFixedWidth(this->width());

    power_pi_filter = new QAction(this);
    power_pi_filter->setText("电源滤波");

    buscap_calc = new QAction(this);
    buscap_calc->setText("母线电容");

    rout_design = new QAction(this);
    rout_design->setText("走线设计");

    check_time = new QAction(this);
    check_time->setText("自检时间");

    mos_drive = new QAction(this);
    mos_drive->setText("自检时间");

    toolbar->addAction(power_pi_filter);
    toolbar->addAction(buscap_calc);
    toolbar->addAction(rout_design);
    toolbar->addAction(check_time);
    toolbar->addAction(mos_drive);

    main_widget = new QStackedWidget(this);
    main_widget->setFixedSize(800, 800);
    main_widget->move(0, toolbar->height());

    connect(buscap_calc, &QAction::triggered, this, &MainWindow::start_buscap_calc);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::start_buscap_calc()
{
    gui_buscap_calc *w = new gui_buscap_calc(this);
    main_widget->addWidget(w);
    main_widget->setCurrentWidget(w);
}
